<?php
namespace Client\Controller;
use Think\Page;

use Think\Controller;
class AccountAddressController extends Controller {
	public function find(){
		if(IS_POST){
			$address = D("AccountAddress");
			$where['account_id'] = $_POST['id'];
			$arr = $address->where($where)->find();
			if($arr){
				$json['result'] = true;
				$json['address'] = $arr;
			}else{
				$json['result'] = false;
			}
			$this->ajaxReturn($json);
		}
	}
	public function query(){
		if(IS_POST){
			$address = D("AccountAddress");
			$where['account_id'] = $_POST['id'];
			$arr = $address->where($where)->select();
			if($arr){
				$json['result'] = true;
				$json['addresses'] = $arr;
			}else{
				$json['result'] = false;
			}
			$this->ajaxReturn($json);
		}
	}
	public function add(){
		if(IS_POST){
			$address = D("AccountAddress");
			$data = $_POST;
			$data = $address->create($data);
			$arr = $address->add($data);
			if($arr){
				$json['result'] = true;
			}else{
				$json['result'] = false;
			}
			$this->ajaxReturn($json);
		}
	}
}